• Jump To … +
    main.js separate.js single.js web-apg-api.js main.js web-conv-api.js ast.js csv.js dangling-else.js display.js flags.js float.js limits.js main.js multiline-mode.js recursive.js replace.js rules.js split.js testonly.js trace.js udt.js unicode.js web-email.js word-boundaries.js main.js phone-number.js web-main.js web-phone-number.js main.js phone-number.js setup.js translate.js xml.js branch-fail-grammar.js main.js parent-mode-grammar.js setup.js universal-mode-grammar.js colors-app.js colors-callbacks.js colors.js main.js more-app.js more-setup.js more.js ast-callbacks.js bad-input.js basic.js ini-file.js main.js parser-callbacks.js setup.js trace.js anbncn.js and.js c-comment.js compound.js main.js nested.js not.js setup.js boundaries-grammar.js boundaries.js comment-grammar.js comment.js main.js negative-grammar.js negative.js positive-grammar.js positive.js setup.js main.js odata-grammar.js run.js setup.js area-code.js lookaround.js main.js phone-number.js setup.js simple.js all-operators.js default.js fancy-number.js limited-lines.js main.js select-operators.js select-rules.js setup.js main.js minimal.js parent-u.js parent.js phone-number.js setup.js stats.js trace.js universal-u.js universal.js callbacks.js grammar.js main.js parser.js writeHtml.js LICENSE.md README.md index.md
  • select-operators.js

  • §
    /*  *************************************************************************************
     *   copyright: Copyright (c) 2021 Lowell D. Thomas, all rights reserved
     *     license: BSD-2-Clause (https://opensource.org/licenses/BSD-2-Clause)
     *   ********************************************************************************* */
  • §

    It is also possible to look at only a specified sub-list of the non-rule name operators. There may be, for example, a literal string that is mysteriously not working the way it should. Here is how to selectively limit the view to some, but not all non-rule name operators.

    (function selectOperators() {
      const setup = require('./setup');
      const { apgLib } = require('apg-js');
  • §

    eslint-disable-next-line new-cap

      const trace = new apgLib.trace();
      let number;
  • §

    By specifying a few operators in particular, this defaults all of the others not specifically named to false.

      trace.filter.operators.tls = true;
      trace.filter.operators.tbs = true;
      trace.filter.operators.trg = true;
  • §

    We are also limiting the rule names.

      trace.filter.rules['phone-number'] = true;
      trace.filter.rules.prefix = true;
      trace.filter.rules.area = true;
      trace.filter.rules.u_office = true;
      trace.filter.rules.subscriber = true;
  • §

    Notice that we are intentionally inserting an error into the phone number. If you inadvertently miss it here, it will be obvious in the final TRG operator in the trace.

      number = ';select operators\n';
      number += ';TLS, TBS & TRG\n';
      number += ';find the error\n';
      number += '(555)888-999A\n';
      setup(trace, number, 'select-operators');
    })();